<template>
	<view class="rechargeBgc">
		<view class="rechargeBox">
			<view class="usableBalance">
				你可兑消的社区币为:<text>{{moneyVal}}</text>个
			</view>
			<view class="WayList">
				<view class="wayBox me-fx-row-sb-c">
					<input type="text" value="" placeholder="请输入兑消数量" @input="onKeyInput"/>
					<text>
						个
					</text>
				</view>
				<view class="wayBox me-fx-row-sb-c">
					<text>预计到账</text>
					<view class="">
						<text>{{getMoney}}</text>元
					</view>
				</view>
			</view>
			<view class="selectWay">
				我的提现账号
			</view>
			<view class="wayBox me-fx-row-sb-c">
				<view class="wayBoxLeft me-fx-row-start-c">
					<image src="../../static/img/Alipay.png" mode=""></image>
					<view class="wayBoxLeftFont">
						微信
					</view>
				</view>
				<view class="">
					{{txaCcount}}
				</view>
			</view>
			<view class="selectWay">
				提现方式
			</view>
			<view class="wayBox me-fx-row-sb-c">
				<view class="wayBoxRight me-fx-row-start-c">
					<image src="../../static/img/Alipay.png" mode=""></image>
					<view class="wayBoxRightFont">
						支付宝
					</view>
				</view>
				<image src="../../static/img/get.png" mode="" class="selectPic"></image>
			</view>
			<view class="rink">
				提现处理时间为周一到周五9:00-18:00,1-3个工作日到账 将遇到问题可联系客服<text>客服微信：jfidoftga</text>
			</view>
		</view>
		<view class="chongzhiBtn" @click="chongzhiBtn">
			提现
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				txaCcount: '',
				leastMoneyVal:'',
				moneyVal:'',
				getMoney:'',
				rateMoney:'',
				inputValue:''
			}
		},
		created() {
			this.dataIndex()
			this.leastMoney()
			this.money()
			this.rate()
		},
		methods: {
			dataIndex() {
				this.$u.get('/withdrawal/account/get').then(res => {
						if (res) {
							console.log(res, 'dsddss')
							this.txaCcount = res.data.data.account
						}
					})
					.catch((res) => {
						console.log(res.message)
					})
			},
			leastMoney() {
				this.$u.get('/withdrawal/min_money').then(res => {
						if (res) {
							this.leastMoneyVal = res.data.money
						}
					})
					.catch((res) => {
						console.log(res.message)
					})
			},
			onKeyInput(e){
				this.getMoney = e.detail.value*this.rateMoney
				this.inputValue =e.detail.value
			},
			rate() {
				this.$u.get('/withdrawal/fee').then(res => {
						if (res) {
							this.rateMoney = res.data.fee
						}
					})
					.catch((res) => {
						console.log(res.message)
					})
			},
			money(){
				this.$u.get('/user/money').then(res => {
						if (res) {
							console.log(res, 'dsddss')
							this.moneyVal = res.data.money
						}
					})
					.catch((res) => {
						console.log(res.message)
					})
			},
			chongzhiBtn(){
				if(parseInt(this.getMoney) < parseInt(this.leastMoneyVal) ){
					uni.showToast({
						title: '提现金额过低',
						duration: 1000,
						icon: 'none'
					});
					return
				}
				if(this.getMoney  < this.moneyVal ){
					uni.showToast({
						title: '对消数量不足',
						duration: 1000,
						icon: 'none'
					});
					return
				}
				let data={
					money:this.inputValue,
					type:2
				}
				this.$u.post('/withdrawal/apply',data).then(res => {
						if (res) {
							console.log(res, 'dsddss')
							uni.showToast({
								title: '提现成功',
								duration: 1000,
								icon: 'none'
							});
							uni.navigateBack({
								delta:2
							})
						}
					})
					.catch((res) => {
					})
			},
		}
	}
</script>

<style>
	.rechargeBgc {
		width: 100%;
		height: 100%;
		background-color: #F5F5F5;
		/* margin-bottom: 110rpx; */

	}

	.rechargeBgc .rechargeBox {
		padding: 20rpx;
		box-sizing: border-box;
	}

	.usableBalance {
		font-size: 30rpx;
		color: rgba(200, 144, 47, 1);
		line-height: 40rpx;
		padding: 32rpx 0;
	}

	.moneyList {
		flex-wrap: wrap;
		align-content: flex-start
	}

	.moneyList .moneyListBox {
		width: 30%;
		width: 222rpx;
		height: 170rpx;
		background: rgba(255, 255, 255, 1);
		border-radius: 8rpx;
		margin-top: 20rpx;
		margin-right: 3%;
		text-align: center;
		color: #666666;
	}

	.moneyList .moneyListBox:nth-last-of-type(3n) {
		margin-right: 0;
	}

	.moneyList .moneyListNum {
		margin-top: 30rpx;
	}

	.moneyList .moneyListNum text {
		font-size: 48rpx;
		color: #333333;
	}

	.moneyList .moneyListMoney {
		font-size: 28rpx;
		margin-top: 10rpx;
	}

	.selectWay {
		font-size: 28rpx;
		color: rgba(102, 102, 102, 1);
		padding: 50rpx 22rpx;
		box-sizing: border-box;
	}

	.WayList {
		width: 100%;
		background-color: white;
		border-radius: 16rpx;
	}

	.wayBox {
		height: 120rpx;
		padding: 0 30rpx;
		background-color: white;
	}

	.wayBox:nth-of-type(2) {
		border-top: 1rpx solid #F5F5F5;
	}

	.wayBoxLeft image,
	.wayBoxRight image {
		width: 52rpx;
		height: 52rpx;
		margin-right: 13rpx;
	}

	.selectPic {
		width: 48rpx;
		height: 32rpx;
	}

	.wayBoxRightFont,
	.wayBoxLeftFont {
		font-size: 32rpx;
		color: rgba(51, 51, 51, 1);
	}

	.chongzhiBtn {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		height: 110rpx;
		background: rgba(92, 20, 255, 1);
		line-height: 110rpx;
		text-align: center;
		color: white;
		font-size: 32rpx;
		font-weight: 700;
	}

	.rink {
		font-size: 26rpx;
		color: rgba(102, 102, 102, 1);
		line-height: 40rpx;
		margin-top: 99rpx
	}

	.rink text {
		color: #5C14FF;
	}
</style>
